/*****************************************
 * Copyright (c) 2008 by AvePoint, Inc
 *
 * AvePoint, Inc.
 * 3 Second Street, Suite 803
 * Jersey City, NJ 07311
 * United States of America
 * Telephone: +1-201-793-1111
 * WWW: www.avepoint.com
 */
package com.myassignment.server;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.util.HashMap;
import java.util.Map;

import com.myassignment.util.Constants;
import com.myassignment.util.DataPacketDto;

public class Gateway2 implements Constants {
    public static void main(String[] args) {
        try {
            byte[] buffer = new byte[1024*1024];
            Map<String, DataPacketDto> table = new HashMap<String, DataPacketDto>();
            DataPacketDto gateWay = new DataPacketDto("GateWay2", "GateWay1");
            gateWay.setTTL(9);
            gateWay.setDelay(30);
            gateWay.setSourceAdress("127.0.0.1");
            gateWay.setTargetPort(Gate_Way_1_Port_Listen);
            table.put(gateWay.getSrcUser(), gateWay);
            DatagramSocket datagramSocket = new DatagramSocket(Gate_Way_2_Port_Listen);
            DatagramPacket datagramPacket = new DatagramPacket(buffer, buffer.length);
            ReceiveService receiver = new ReceiveService(datagramSocket, datagramPacket, table, "GateWay2");
            Thread t = new Thread(receiver);
            t.start();
            System.out.println("Gateway2 is start up......");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}